package com.jxzyk;

import java.util.ArrayList;
import java.util.List;

import android.app.Application;

import com.alibaba.fastjson.JSONArray;
import com.core.entity.I_List;
import com.core.util.ACache;
import com.jxzyk.config.ConfigHelper;
import com.jxzyk.entity.CourseType;

public class App extends Application {
	public static ConfigHelper helper = new ConfigHelper();
	private static ACache mACache;

	private static final String KEY_TYPE = "CourseType";

	public static List<I_List> getCourseType() throws Exception {
		List<I_List> data = new ArrayList<>();
		String arrayString = mACache.getAsString(KEY_TYPE);
		JSONArray array = JSONArray.parseArray(arrayString);
		for (int i = 0; i < array.size(); i++) {
			CourseType type = (CourseType) new CourseType().instance(array
					.getJSONObject(i));
			data.add(type);
		}
		return data;
	}

	public void setCourseType(String arrayString) {
		mACache.put(KEY_TYPE, arrayString);
	}

	@Override
	public void onCreate() {
		super.onCreate();
		mACache = ACache.get(getApplicationContext());
		helper.init(getApplicationContext());
	}

}
